<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class TurnStatus {

	public function __construct(){
		$this->id = -1;
		$this->on = 0;		//开关
		$this->name = "基类";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->astype = 0;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 0;		//关联数组里的状态编号
	}
	
	public function run_turn($a) {
		$this->n += 1;
		switch($this->astype) {
		case 0:{$a->defskill_status[$this->aid]->n += 1;break;}
		case 1:{$a->atkskill_status[$this->aid]->n += 1;break;}
		default:{;}
		}
		if($this->n > $this->time) {
			$this->on = 0;
			$this->n = 1;
			switch($this->astype) {
			case 0:{$a->defskill_status[$this->aid]->cancel($a);break;}
			case 1:{$a->atkskill_status[$this->aid]->cancel($a);break;}
			default:{;}
			}
			$_SESSION['show'] .= $a->name.$this->name."的状态恢复了。<br>";
		}
	}
}

class BadAirTurn extends TurnStatus {

	public function __construct(){
		$this->id = 0;
		$this->on = 0;		//开关
		$this->name = "淀んだ空気";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 3;	//持续回合数
		$this->astype = 0;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 2;		//关联数组里的状态编号
	}

}

class GuardStarsTurn extends TurnStatus {

	public function __construct(){
		$this->id = 1;
		$this->on = 0;		//开关
		$this->name = "二十八宿の守護";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 3;	//持续回合数
		$this->astype = 0;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 6;		//关联数组里的状态编号
	}

}
class CrtUp15Turn extends TurnStatus {

	public function __construct(){
		$this->id = 2;
		$this->on = 0;		//开关
		$this->name = "リベリオン";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 3;
		$this->astype = 1;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 2;		//关联数组里的状态编号
	}

}

class CrtUp30Turn extends TurnStatus {

	public function __construct(){
		$this->id = 3;
		$this->on = 0;		//开关
		$this->name = "レボリューション";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 3;
		$this->astype = 1;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 3;		//关联数组里的状态编号
	}

}

class SBargainTurn extends TurnStatus {

	public function __construct(){
		$this->id = 4;
		$this->on = 0;		//开关
		$this->name = "静天の契り";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 5;
		$this->astype = 0;	//关联状态数组类型，0 = defskill_status;1 = atkskill_status
		$this->aid = 10;		//关联数组里的状态编号
	}

}

class Escaped extends TurnStatus {

	public function __construct(){
		$this->id = 5;
		$this->on = 0;		//开关
		$this->name = "撤退";
		$this->n = 1;		//当前进行次数，回合类必须默认为1
		$this->time = 3;
	}

	public function run_turn($a) {
		$this->n += 1;
		if($this->n > $this->time) {
			$this->on = 0;
			$this->n = 1;
			$a->escaping = 0;
			list($group,$key) = CalHelper::getitbyuuid($a->uuid);
			foreach($_SESSION[$group] as $sg) {
				if($sg->recoverap) $sg->recoverap -= 2;
			}
			$_SESSION['show'] .= $a->name."回到了本方阵营<br>";
		} else {
			$_SESSION['show'] .= $a->name."精力恢复中...<br>";
			$plushp = round($a->mxhp * 0.15);
			$plussp = round($a->mxsp * 0.15);
			$a->hp = ($a->hp + $plushp > $a->mxhp) ? $a->mxhp : ($a->hp + $plushp);
			$a->sp = ($a->sp + $plussp > $a->mxsp) ? $a->mxsp : ($a->sp + $plussp);
		}
	}
}

?>
